<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>rc03</title>
    <style>
        body{
            overflow: hidden;
            width: 100%;
        }
        .section {
          height: 100vh;
          background-position: center;
        }
    </style>
</head>
<body>
    
    <div class="section" style="background-image: url('1.png');"></div>
    <div class="section" style="background-image: url('2.png');"></div>
    <div class="section" style="background-image: url('3.png');"></div>
  
    <script>

        const sections = document.getElementsByClassName('section');

        let currentSectionIndex = 0;

        window.addEventListener('wheel',function(event){
            // console.log(event.deltaY);
            if(event.deltaY > 0){
                if(currentSectionIndex < sections.length-1){
                    currentSectionIndex +=1;
                        scrollToSection(currentSectionIndex);
                }
            }else{
                if(currentSectionIndex != 0){
                    currentSectionIndex -=1;
                        scrollToSection(currentSectionIndex);
                }
            }
        })

        function scrollToSection(index){
            sections[index].scrollIntoView({behavior:"smooth"})
        }
    </script>
</body>
</html>